@extends('layouts.app')

@section('content')
<div class="container" id="container">
        <div class="wrapper">
            <div id="minHeight" class="minHeight">
                <div class="wrapper">
                   @include('common.header', ['title' => translate('找回密码')])
                    <div class="main_body">
                        <div class="reg">
                        	 @if(session('status')==3)
                            	 <form class="form-horizontal" id="ff" method="POST" action="{{ route('password.resetsPassword') }}">
                                        {{ csrf_field() }}
                        	<div id="login" name="login">
                                <div class="control-group">
                                    <input type="text" name="password" id="new" class="input-style1" placeholder="{{translate('新密码')}}">
                                </div>
                                <div class="control-group">
                                    <input type="text" name="repassword" id="sure" class="input-style1" placeholder="{{translate('确认密码')}}">
                                </div>
                                <div class="control-group">
                                    <a class="btn-style1" id="submits">{{translate('完成')}}</a>
                                </div>
                            </div>
                            </form>
                            @else
                            <form class="form-horizontal" id="ff" method="POST" action="{{ route('password.email') }}">
                        {{ csrf_field() }}
                            <div id="login" name="login">


                                <div class="control-group">
                                    <input type="text" name="mobile" id="phone" class="input-style1" placeholder="{{translate('请输入手机号码')}}">
                                </div>
                                <div class="control-group msg">
                                    <input type="text" id="msgcode" class="msgcode" name="code" maxlength="5" placeholder="{{translate('输入您收到的短信验证码')}}">
                                    <a href="javascript:SendPhone();" id="sendCode" style="background-color: #999" class="sendcode">{{translate('获取验证码')}}</a>
                                </div>
                                <div class="control-group">
                                    <a premit="0" class="btn-style1" id="submit">{{translate('下一步')}}</a>
                                </div>

                            </div>
                            </form>
                            @endif
                        </div>
                    </div>
                </div>

            </div>
        </div>
    </div>


    <script>

    $(function () {
        // $("#phone").change(function () {
        //     alert("手机号已改变");
        //     $("#submit").attr("premit",0);
        // });
		$('#submits').click(function(){
			if( $("#new").val() != $("#sure").val() || $("#new").val().length < 6)
            {
				layer.msg("{{translate('请正确填写密码')}}");
                return;
            }
			$('#ff').submit()
		})
        $("#submit").click(function () {    //提交

            if( $("#phone").val().length != 11 || $("#msgcode").val().length <= 0 )
            {
            	layer.msg("{{translate('请填写完整')}}");
                return;
            }
            var phone = $("#phone").val();  //手机号
            if( phone.length != 11 )
            {
            	layer.msg("{{translate('请输入正确的手机号')}}");
                return;
            }
            var code = $("#msgcode").val();
            $('#ff').submit()


        });

    })

    function SendPhone() {      //发送验证码
        var phone = $("#phone").val();  //手机号
        if( phone.length != 11 )
        {
        	layer.msg("{{translate('请输入正确的手机号')}}");
            return;
        }
        $.ajax({
            url:"/sendsms",
            data:{mobile:phone,type:'reset'},
            type:"post",
            dataType:"json",
            success:function(result){
                //console.log(result);
                if( result.Statu == 0 )
                {
                    $("#submit").attr("premit",1);
                    layer.msg(result.Msg);
                }
                else
                {
                	layer.msg(result.Msg);
                }
            },
            error:function(){
            	layer.msg("{{translate('请求失败')}}");
            }
        });
    }
</script>

@endsection
